/**
 * 匠言知识付费v2.0.0
 * Author: 山西匠言网络科技有限公司
 * 这不是一个免费软件，它受限于许可条款，你可以访问https://www.zsfzxkc.cn/获取更多详细信息。
 * This is not a free software, it under the license terms, you can visit https://www.zsffzxkc.cn/ get more details.
 */
<template>
	<view class="container" v-if="is_verify==true">
		<jy-quick-btns></jy-quick-btns>
		<view class="beijing">
			<image src="../static/jslive.jpg" mode="aspectFit"></image>
			<view class="info">
				<image :src="tinfo.img?tinfo.img:userinfo.avatar" mode=""></image>
				<text>{{tinfo.imgname}}</text>
			</view>
		</view>
		
		<!-- 列表部分 -->
		<view class="teacher-center-list">

			<view class="teacher-center-list-item" @click="navigate('manage-course')">
				<view class="item-left">
					<image src="../static/video.png" mode="aspectFit"></image>
					<text>我的课程</text>
				</view>
				<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
			</view>
			<view class="teacher-center-list-item" @click="navigate('coursemenu-add')">
				<view class="item-left">
					<image src="../static/upload.png" mode="aspectFit"></image>
					<text>添加课程目录</text>
				</view>
				<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
			</view>
			<view class="teacher-center-list-item" @click="navigate('video-course-add')">
				<view class="item-left">
					<image src="../static/video-upload.png" mode="aspectFit"></image>
					<text>添加课时</text>
				</view>
				<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
			</view>
			<view class="teacher-center-list-item" @click="navigate('brokerage')">
				<view class="item-left">
					<image src="../static/shouyi1.png" mode="aspectFit"></image>
					<text>我的收益</text>
				</view>
				<image class="item-right" src="../static/xiangyou11.png" mode="aspectFit"></image>
			</view>
		</view>
	</view>
	<view class="verify" v-else>
		<view class="">
			讲师资料审核中...
		</view>
		<button type="primary" @click="backuser">返回个人中心</button>
	</view>
</template>

<script>
	import {checkUserinfo} from '@/request/checkUserinfo'
	export default {
		data() {
			return {
				userinfo: {},
				tinfo:{},
				is_verify:false
			};
		},
		onShareAppMessage(res) {
			let path = getCurrentPages()
			let path_share = path[0].$page.fullPath
			let path_title = path[0].data.title
			let userinfo = uni.getStorageSync('userinfo')
			let base_set = uni.getStorageSync('base_set')
			if(userinfo.uid=='' || !userinfo.uid){
				uni.navigateTo({
					url:'../login/login'
				})
				return {
					title: '请先登录后再分享给好友',
					path: ''
				}
			}else{
				if (res.from === 'button') {
					
				}
				return {
					title: base_set.title,
					path: `${path_share}?pid=${userinfo.uid}`
				}
			}
		},
		onShow() {
			checkUserinfo()
			let userinfo=uni.getStorageSync('userinfo')
			this.userinfo = userinfo.userdata
			if(userinfo){
				this.checkTinfo(userinfo.uid)
			}
			
		},
		methods: {
			backuser(){
				uni.navigateTo({
					url:'../user/user'
				})
			},
			checkTinfo(uid){
				const BASE_URL = uni.BASE_URL
				uni.request({
					url: BASE_URL+'index/teacher/tinfo',
					method:'POST',
					data:{
						uid:uid,
					},
					success:(res) =>{
						console.log(res.data);
						if(res.data.code==0){
							this.tinfo=res.data.data
							if(res.data.data.is_verify==1 || res.data.data.is_test==1){
								this.is_verify=true
							}else{
								this.is_verify=false
							}
						}else{
							uni.navigateTo({
								url:'../recruit/recruit'
							})
						}
					},
					fail:(res)=> {
						console.log(res.data);
					}
				});
			},
			navigate (e) {
				
				// #ifdef H5
				if(e==('course-add' || 'livelist')){
					uni.showToast({
						title:'请使用小程序或APP版本进行直播！',
						icon:'none'
					})
				}else{
					if(e=='brokerage'){
						uni.navigateTo({
							url: `../../fenxiao/${e}/${e}?tid=${this.tinfo.id}`
						});
					}else{
						uni.navigateTo({
							url: `../${e}/${e}?tid=${this.tinfo.id}`
						});
					}
				}
				// #endif
				// #ifndef H5
				if(e=='livelist'){
					uni.navigateTo({
						url: `../../course-list/course-list?tid=${this.tinfo.id}&media=live&goodtype=course`
					});
				}else{
					if(e=='brokerage'){
						uni.navigateTo({
							url: `../../fenxiao/${e}/${e}?tid=${this.tinfo.id}`
						});
					}else{
						uni.navigateTo({
							url: `../${e}/${e}?tid=${this.tinfo.id}`
						});
					}
				}
				// #endif
			}
		}
	}
</script>

<style lang="less" scoped>
.beijing {
	image {
		width: 750upx;
		height: 275upx;
	}
	.info {
		display: flex;
		flex-direction: column;
		align-items: center;
		position: absolute;
		top: 30upx;
		left: 300upx;
		image {
			width: 120upx;
			height: 120upx;
			border-radius: 50%;
		}
		text {
			font-size: 30upx;
			color: #fff;
			text-shadow:#555 6upx 8upx 10upx;
			margin-top: 20upx;
		}
	}
}

.teacher-center-list {
	&-item {
		height: 100upx;
		padding: 0 30upx;
		border-bottom: 2upx solid #ddd;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.item-left {
			display: flex;
			align-items: center;
			image {
				width: 60upx;
				height: 60upx;
			}
			text {
				font-size: 30upx;
				color: #333;
				margin-left: 30upx;
			}
		}
		.item-right {
			width: 20upx;
			height: 30upx;
		}
	}
}
.verify{
	text-align: center;
	font-size: 32upx;
	padding-top: 50upx;
	button{
		width: 60%;
		margin-top: 100upx;
	}
}
</style>
